package com.chatplus.application.domain.response.admin;

import com.chatplus.application.domain.entity.file.SysOssConfigEntity;
import com.chatplus.application.json.Int64AsString;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;


/**
 * 对象存储配置视图对象
 */
@Data
public class SysOssConfigResponse implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主建
     */
    @JsonSerialize(using = Int64AsString.class)
    private Long id;
    /**
     * 配置key
     */
    private String configKey;
    /**
     * accessKey
     */
    private String accessKey;
    /**
     * 秘钥
     */
    private String secretKey;
    /**
     * 桶名称
     */
    private String bucketName;
    /**
     * 前缀
     */
    private String prefix;
    /**
     * 访问站点
     */
    private String endpoint;
    /**
     * 自定义域名
     */
    private String domain;
    /**
     * 是否https（1=是,0=否）
     */
    private Boolean https;
    /**
     * 域
     */
    private String region;
    /**
     * 桶权限类型(0=private 1=public 2=custom)
     */
    private String accessPolicy;
    /**
     * 状态（0=正常,1=停用）
     */
    private Boolean status;
    /**
     * 是否默认
     */
    private Boolean defaultStore;
    /**
     * 扩展字段
     */
    private String ext1;
    /**
     * 备注
     */
    private String remark;

    public static SysOssConfigResponse build(SysOssConfigEntity sysOssConfigEntity) {
        if (sysOssConfigEntity == null) {
            return null;
        }
        SysOssConfigResponse sysOssConfigResponse = new SysOssConfigResponse();
        sysOssConfigResponse.setId(sysOssConfigEntity.getId());
        sysOssConfigResponse.setConfigKey(sysOssConfigEntity.getConfigKey());
        sysOssConfigResponse.setAccessKey(sysOssConfigEntity.getAccessKey());
        sysOssConfigResponse.setSecretKey(sysOssConfigEntity.getSecretKey());
        sysOssConfigResponse.setBucketName(sysOssConfigEntity.getBucketName());
        sysOssConfigResponse.setPrefix(sysOssConfigEntity.getPrefix());
        sysOssConfigResponse.setEndpoint(sysOssConfigEntity.getEndpoint());
        sysOssConfigResponse.setDomain(sysOssConfigEntity.getDomain());
        sysOssConfigResponse.setHttps(sysOssConfigEntity.getHttps());
        sysOssConfigResponse.setRegion(sysOssConfigEntity.getRegion());
        sysOssConfigResponse.setAccessPolicy(sysOssConfigEntity.getAccessPolicy());
        sysOssConfigResponse.setStatus(sysOssConfigEntity.getStatus());
        sysOssConfigResponse.setDefaultStore(sysOssConfigEntity.getDefaultStore());
        sysOssConfigResponse.setExt1(sysOssConfigEntity.getExt1());
        sysOssConfigResponse.setRemark(sysOssConfigEntity.getRemark());
        return sysOssConfigResponse;
    }
}
